this._scrollView.add_action(action);
this._deletingFolder = false;
- this._appIds = [];
+ this._apps = [];
this._redisplay();
}
return new FolderGrid();
}
- _getFolderApps() {
- const appIds = [];
- const excludedApps = this._folder.get_strv('excluded-apps');
- const appSys = Shell.AppSystem.get_default();
- const addAppId = appId => {
- if (excludedApps.includes(appId))
- return;
-
- if (this._appFavorites.isFavorite(appId))
- return;
-
- const app = appSys.lookup_app(appId);
- if (!app)
- return;
-
- if (!this._parentalControlsManager.shouldShowApp(app.get_app_info()))
- return;
-
- if (appIds.indexOf(appId) !== -1)
- return;
-
- appIds.push(appId);
- };
-
- const folderApps = this._folder.get_strv('apps');
- folderApps.forEach(addAppId);
-
- const folderCategories = this._folder.get_strv('categories');
- const appInfos = this._parentView.getAppInfos();
- appInfos.forEach(appInfo => {
- let appCategories = _getCategories(appInfo);
- if (!_listsIntersect(folderCategories, appCategories))
- return;
-
- addAppId(appInfo.get_id());
- });
-
- return appIds;
- }
-
_getItemPosition(item) {
- const appIndex = this._appIds.indexOf(item.id);
+ const appIndex = this._apps.indexOf(item.app);
if (appIndex === -1)
return [-1, -1];
}
_compareItems(a, b) {
- const aPosition = this._appIds.indexOf(a.id);
- const bPosition = this._appIds.indexOf(b.id);
+ const aPosition = this._apps.indexOf(a.app);
+ const bPosition = this._apps.indexOf(b.app);
if (aPosition === -1 && bPosition === -1)
return a.name.localeCompare(b.name);
}
_loadApps() {
- let apps = [];
- let appSys = Shell.AppSystem.get_default();
+ this._apps = [];
+ const excludedApps = this._folder.get_strv('excluded-apps');
+ const appSys = Shell.AppSystem.get_default();
+ const addAppId = appId => {
+ if (excludedApps.includes(appId))
+ return;
+
+ if (this._appFavorites.isFavorite(appId))
+ return;
- this._appIds.forEach(appId => {
const app = appSys.lookup_app(appId);
+ if (!app)
+ return;
- let icon = this._items.get(appId);
- if (!icon)
- icon = new AppIcon(app);
+ if (!this._parentalControlsManager.shouldShowApp(app.get_app_info()))
+ return;
+
+ if (this._apps.indexOf(app) !== -1)
+ return;
+
+ this._apps.push(app);
+ };
+
+ const folderApps = this._folder.get_strv('apps');
+ folderApps.forEach(addAppId);
+
+ const folderCategories = this._folder.get_strv('categories');
+ const appInfos = this._parentView.getAppInfos();
+ appInfos.forEach(appInfo => {
+ let appCategories = _getCategories(appInfo);
+ if (!_listsIntersect(folderCategories, appCategories))
+ return;
- apps.push(icon);
+ addAppId(appInfo.get_id());
});
- return apps;
- }
+ let items = [];
+ this._apps.forEach(app => {
+ let icon = this._items.get(app.get_id());
+ if (!icon)
+ icon = new AppIcon(app);
- _redisplay() {
- // Keep the app ids list cached
- this._appIds = this._getFolderApps();
+ items.push(icon);
+ });
- super._redisplay();
+ return items;
}
acceptDrop(source) {